import request from './request';

const blog = {
    // 获取博客列表
    getBlogListApi() {
        return request.get('/api/blogs');
    },

    // 获取博客详情
    getBlogDetailApi(id) {
        return request.get(`/api/blogs/${id}`);
    },

    // 创建博客
    createBlogApi(data) {
        return request.post('/api/blogs', data);
    },

    // 编辑博客
    editBlogApi(id, data) {
        return request.put(`/api/blogs/${id}`, data);
    },

    // 删除博客
    deleteBlogApi(id) {
        return request.delete(`/api/blogs/${id}`);
    },

    //点赞博客
    likeBlogApi(id) {
        return request.post(`/api/blogs/${id}/like`);
    },

    //取消点赞博客
    unLikeBlogApi(id) {
        return request.delete(`/api/blogs/${id}/like`);
    },

    //收藏博客
    favoriteBlogApi(id) {
        return request.post(`/api/blogs/${id}/favorite`);
    },

    //取消收藏博客
    unFavoriteBlogApi(id) {
        return request.delete(`/api/blogs/${id}/favorite`);
    },
};

export default blog;